﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Net.Http;
using System.Threading.Tasks; 
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;
using Newtonsoft.Json;
using XXX.Bo;
using XXX.Common;
using XXX.Models.JWT;
using XXX.Models.XXXEntities;

// For more information on enabling Web API for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860

namespace XXX.api.Controllers
{
    [Route("api/account/[controller]")]
    [ApiController]
    public class ST_PDALoginController : ControllerBase
    {
      
        private readonly ILogger<ST_PDALoginController> _logger;
        public ST_PDALoginController( ILogger<ST_PDALoginController> logger)
        {
            _logger = logger;
        }

        [HttpGet]
        public Models.RetModel2 Post(string userid,string password)
        {
             
            //默认的账套
            Models.RetModelbool ret = DBService.AA_GetUserLoginU8(CanShu.conStr, userid, password);
            if (ret.code==200)
            {
                ResponseToken response =  new TokenHelper().CreateToken(userid);
                
                return new Models.RetModel2() { code = 200,message = ret.message, data = response };
            }
            else
            {
                return  DBService.ReErrObject(ret.message);
            }
              
            
        }


        [HttpPost]
        public Models.RetModelbool Post([FromBody]Models.XXXEntities.User model)
        {
            //默认的账套
            Models.RetModelbool ret = DBService.AA_GetUserLoginU8(CanShu.conStr, model.userid,model.password);
                return ret;
        }


    }
}
